<template>
    <div>
        <Form ref="formInline" :model="formInline" inline>
            <FormItem prop="输入部门名称">
                <Input type="text" v-model="formInline.department_name" placeholder="输入部门名称">
                </Input>
            </FormItem>
            <FormItem>
                <Button type="primary" @click="search()">搜索</Button>
            </FormItem>
        </Form>
<!--        <Input search placeholder="输入部门名称"  v-model="value1" @on-enter="select" style="width: 400px;margin: 30px 0 40px 0"/>-->
        <Table border :columns="columns12" :data="data6" show-summary >
<!--            <Table :columns="columns15" :data="data11" border show-summary :summary-method="handleSummary" height="200"></Table>-->
            <template slot-scope="{ row }" slot="name">
                <strong>{{ row.name }}</strong>
            </template>
            <template slot-scope="{ row}" slot="action">
                <Button type="primary" size="small" style="margin-right: 5px" @click="show(row)">查看</Button>
            </template>
        </Table>
<!--        <Page :total="100" style="float: right;margin-top: 20px" @on-change="aa"/>-->
        <Page :total="params.totalRecord" show-sizer :page-size="params.pageSize" style="float: right;margin-top: 20px"
              show-total @on-change="aa" @on-page-size-change="pSizeChange" />
    </div>
</template>

<script>
import { GetZlUnityList } from '@/api/user'
export default {

  data () {
    return {
      formInline: {
        department_name: ''
      },
      value1: '',
      columns12: [
        {
          title: '序号列',
          type: 'index',
          align: 'center',
          width: 80
        },
        {
          title: '单位名称',
          key: 'department_name',
          align: 'center',
          width: 200
        },
        {
          title: '会议标题',
          key: 'title',
          align: 'center',
          width: 200
        },
        {
          title: '会议日期',
          key: 'meeting_time',
          align: 'center',
          width: 150
        },
        {
          title: '参会人数',
          key: 'meeting_num',
          width: 100,
          align: 'center'
        },
        {
          title: '其中市管干部人数',
          key: 'cadre_num',
          width: 100,
          align: 'center'
        },
        {
          title: '中层干部（处级）人数',
          key: 'middle_cadres_num',
          width: 100,
          align: 'center'
        },
        {
          title: '其他人数',
          key: 'other_num',
          width: 100,
          align: 'center'
        },
        // {
        //   title: '人数合计',
        //   key: 'tatol',
        //   align: 'center',
        //   width: 100
        // },
        {
          title: '最后更新时间',
          key: 'update_time',
          width: 200,
          align: 'center'
        },
        {
          title: '操作',
          fixed: 'right',
          slot: 'action',
          width: 150,
          align: 'center'
        }
      ],
      data6: [],
      params: { pageNo: 1, pageSize: 10, totalRecord: 0 }
    }
  },

  props: {

  },

  components: {

  },

  computed: {

  },

  methods: {
    aa (current) {
      GetZlUnityList({ pageNo: current }).then(ret => {
        let data = ret.data.data.results

        console.log(data)
        // data.forEach(item => {
        //   let num = parseInt(item.meeting_num || '0') + parseInt(item.cadre_num || '0') + parseInt(item.middle_cadres_num || '0') + parseInt(item.other_num || '0')
        //   item['tatol'] = num
        //   item.update_time = this.$common.xeUtils.toDateString(item.update_time)
        // })
        this.data6 = data
      })
    },
    pSizeChange (val) {
      GetZlUnityList({ pageSize: val }).then(ret => {
        let data = ret.data.data.results
        this.data6 = data
      })
    },
    // select () {
    //   GetZlUnityList({ department_name: this.value1 }).then(ret => {
    //     this.data6 = ret.data.data.results
    //   })
    // },
    search () {
      GetZlUnityList({ department_name: this.formInline.department_name }).then(ret => {
        this.data6 = ret.data.data.results
        this.params.totalRecord = ret.data.data.totalRecord
      })
    },
    show (row) {
      this.$router.push({
        path: 'IdeologicalCognitionf',
        query: { a: row }
      })
    },
    a () {
      console.log(this.$store.state.user.severUserInfo.data.company_name, 'cd')
      GetZlUnityList({}).then(ret => {
        let data = ret.data.data.results
        console.log(data)
        data.forEach(item => {
          item.update_time = this.$common.xeUtils.toDateString(item.update_time)
          let a = new Date(item.meeting_time)
          let y = a.getFullYear()
          let m = a.getMonth() + 1
          let d = a.getDate()
          if (m < 10) {
            m = '0' + m
          }
          if (d < 10) {
            d = '0' + d
          }
          item.meeting_time = y + '-' + m + '-' + d
        })
        this.data6 = data
        this.params.totalRecord = ret.data.data.totalRecord
      })
    }
  },
  watch: {
  },
  mounted () {
    this.a()
  }

}
</script>

<style scoped>

</style>
